import request from 'utils/request';

export const getArticleListAPI = (params) => {
  return request({
    url: '/v1_0/mp/articles',
    method: 'get',
    params,
  });
};

export const delArticleByIdAPI = (id) => {
  return request({
    url: `/v1_0/mp/articles/${id}`,
    method: 'delete',
  });
};

/**
 * 发送请求添加文章
 * @param {*} data
 * @returns
 */
export const addArticleAPI = (data, draft = false) => {
  return request({
    url: `/v1_0/mp/articles?draft=${draft}`,
    method: 'post',
    data,
  });
};

/**
 * 获取文章详情信息
 * @param {*} id
 * @returns
 */
export const getArticleByIdAPI = (id) => {
  return request.get(`/v1_0/mp/articles/${id}`);
};

/**
 * 修改文章的接口
 * @param {*} data
 * @param {*} draft
 * @returns
 */
export const updateArticleAPI = (data, draft) => {
  return request({
    url: `/v1_0/mp/articles/${data.id}?draft=${draft}`,
    method: 'PUT',
    data,
  });
};
